<html>
<head><meta charset="utf-8"><title>Philosophy of derive · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Philosophy.20of.20derive.html">Philosophy of derive</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241863189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Philosophy%20of%20derive/near/241863189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Philosophy.20of.20derive.html#241863189">(Jun 08 2021 at 02:02)</a>:</h4>
<p><span class="user-mention silent" data-user-id="220273">Jane Lusby</span> <a href="#narrow/stream/219381-t-libs/topic/.23.5Bderive.28Default.29.5D.20on.20enums.20.E2.80.94.20non-exhaustive.20interaction/near/241854398">said</a>:</p>
<blockquote>
<blockquote>
<p>I think the "non-structuralness" is the bigger factor. Every other derive (that generates any methods) cares about all the variants. This would be the only one that doesn't.</p>
</blockquote>
<p>this strikes me as a justification after the fact, I'm not confident that this is the source of the current unstated policy. My guess at the history of derives all being very structural is that it's because those were the easiest / least bikeshed-y, not because people didn't want to go beyond that.</p>
</blockquote>
<p>I guess there's a philosophical question there about whether <code>derive</code> is supposed to have any meaning other that "arbitrary codegen here".  I've always considered it to imply a sort of map-reduce -- even serde's complicated derives are still the general "combine the calls to the same trait on the subfields" structure.</p>
<p>It's unclear to me whether this is also affected by there having been a long time where there wasn't any option available between <a href="http://do-it-in-build.rs">do-it-in-build.rs</a> and do-it-in-a-derive.</p>



<a name="241863761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Philosophy%20of%20derive/near/241863761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Philosophy.20of.20derive.html#241863761">(Jun 08 2021 at 02:15)</a>:</h4>
<p><code>derive</code> should just mean "give me the standard way of doing this".</p>



<a name="241927586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Philosophy%20of%20derive/near/241927586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Philosophy.20of.20derive.html#241927586">(Jun 08 2021 at 14:25)</a>:</h4>
<p>Agreed; the point of derive should be to "do the right/obvious thing".</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>